import java.util.Stack;
//栈的压入、弹出序列
public class Solution1 {
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        Stack<Integer> stack = new Stack<>();
        int i = 0;
        int j = 0;
        for(i = 0; i < pushV.length; i++) {
            stack.push(pushV[i]);
            while(j < pushV.length && !stack.empty() && stack.peek() == popV[j]) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
}
